package com.one.group.utils;


import com.one.group.enums.ErrorCode;
import com.one.group.result.Result;

/**
 * {@code @Create:}  2025-09-28  12 : 37
 * {@code @Author:} Cherry
 * {@code @ToUser:} 凡是发生,皆有利于我。
 * ------------------------------------
 * {@code @note:}
 */

@SuppressWarnings({"all"})
public class ResultUtil {
    public static <T> Result<T> success() {
        return new Result<>(0, null, "操作成功");
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(0, data, "操作成功");
    }

    public static <T> Result<T> success(Integer code, T data) {
        return new Result<>(code, data);
    }

    public static <T> Result<T> error(ErrorCode errorCode) {
        return new Result<>(errorCode);
    }

    public static <T> Result<T> error(Integer code, String message) {
        return new Result<>(code, null, message);
    }

    public static <T> Result<T> error(ErrorCode errorCode, String message) {
        return new Result<>(errorCode.getCode(), null, message);
    }
}
